package com.ch.engine.design.observe;

/**
 * 具体的观察者类
 *
 * @author wangchunhui
 * @date 2023/12/12 11:13
 */
public class ConcreteObserver implements Observer {

    private int observerState;
    private ConcreteSubject subject;

    public ConcreteObserver(ConcreteSubject subject) {
        this.subject = subject;
        this.subject.registerObserver(this);
    }

    @Override
    public void update() {
        observerState = subject.getState();
        System.out.println("Observer state updated: " + observerState);
    }
}